<?php
/*
 * 金卡专户
 * @package    member
 * @author     WL
 * @copyright  Copyright (c) 2013 ixdcw team
 * @version    $Id: 155b17956db17a26bb1b59394300ebafa4723591 $
 */
defined('IN_IXDCW') or exit('Access Denied');
login();
require DT_CORE.'/'.$module.'/common.inc.php';
require_once DT_INC.'/post.func.php';
isset($fromtime) or $fromtime = '';
isset($totime) or $totime = '';

$condition = "username='$_username'";
if($fromtime) $condition .= " AND addtime>".(strtotime($fromtime.' 00:00:00'));
if($totime) $condition .= " AND addtime<".(strtotime($totime.' 23:59:59'));
$r = $db->getOne("SELECT COUNT(*) AS num FROM {$db->getPre()}finance_cardmoney WHERE $condition");
$pages = pages($r['num'], $page, $pagesize);
$records = array();
$result = $db->query("SELECT * FROM {$db->getPre()}finance_cardmoney WHERE $condition ORDER BY itemid DESC LIMIT $offset,$pagesize");
$income = $expense = 0;

while($r = $db->fetchArray($result)) {
	$r['addtime'] = timetodate($r['addtime'], 5);
	$r['amount'] > 0 ? $income += $r['amount'] : $expense += $r['amount'];
	$records[] = $r;
}

include template('cardmoney', $module);
?>